from django.db import models
#from django.contrib.auth.models import User

GENDERS = (
    ('M', 'male'),
    ('F', 'female'),
    ('TM', 'trans male'),
    ('TF', 'trans female'),
    ('Q', 'genderqueer'),
)

LOCATIONS = (
    ('EB', 'East Bay'),
    ('SB', 'South Bay'),
    ('SF', 'San Francisco'),
    ('NB', 'North Bay'),
    ('PN', 'Peninsula'),
    ('SE', 'somewhere else'),
)

KINKINESSES = (
    ('K', 'kinky only'),
    ('NK', 'non-kinky only'),
    ('EI', 'either is fine'),
)

class Person(models.Model):
    first_name = models.CharField(max_length=30, verbose_name="First Name")
    last_name = models.CharField(max_length=30, verbose_name="Last Name")
    gender = models.CharField(max_length=20, verbose_name="Gender")
    age = models.PositiveIntegerField(verbose_name="Age")
    seeking_primary = models.BooleanField(verbose_name="Seeking Primary (Y/N)")
    kinky = models.BooleanField(verbose_name="Kinky (Y/N)")
    seek_gender = models.CharField(max_length=20, verbose_name="Genders Wanted")
    seek_age_min = models.PositiveIntegerField(verbose_name="Minimum Age Wanted")
    seek_age_max = models.PositiveIntegerField(verbose_name="Maximum Age Wanted")
    seek_kinkiness = models.CharField(max_length=2, verbose_name="Kinkiness Wanted")
    psdid = models.CharField(max_length=6, blank=True)

    def __unicode__(self):
        return self.first_name + ' ' + self.last_name

class RegRecord(models.Model):
    nickname = models.CharField(max_length=30, verbose_name="Nickname")
    email = models.EmailField(verbose_name="Email")
    add_to_mailings = models.BooleanField(default=True, verbose_name="Join Our Mailing List (Y/N)")
    #previous_id = models.CharField(max_length=8, blank=True, verbose_name="Previous Poly Speed Dating ID")
    seek_groups = models.BooleanField(verbose_name="Date Groups (Y/N)")
    groups_match_all = models.BooleanField(verbose_name="All Group Members Must Match (Y/N)")
    friend_dates = models.BooleanField(verbose_name="Friend Dates (Y/N)")
    referred_by = models.CharField(max_length=30, blank=True, verbose_name="Referred By")
    pals = models.TextField(blank=True, verbose_name="Friends")
    location = models.CharField(max_length=30, blank=True, verbose_name="Location")
    wants_childcare = models.BooleanField(verbose_name="Need Childcare (Y/N)")
    children = models.TextField(blank=True, verbose_name="Children")
    comments = models.TextField(blank=True, verbose_name="Comments")
    event = models.CharField(max_length=10, blank=True)
    people = models.ManyToManyField(Person, blank=True)
    #user = models.OneToOneField(User, null=True, blank=True)
    psdid = models.CharField(max_length=6, blank=True)
    paid = models.BooleanField(default=False)
    cancelled = models.BooleanField(default=False)
    pending = models.BooleanField(default=False)
    here = models.BooleanField(default=False)
    stationary = models.BooleanField(default=False)
    is_group = models.BooleanField(default=False)
    notes = models.TextField(blank=True)
    geek_code = models.TextField(blank=True)
    matches = models.IntegerField(blank=True, null=True, default=0)
    oneway = models.IntegerField(blank=True, null=True, default=0)

    def __unicode__(self):
        return "%s reg %s - %s" % (self.event, self.psdid, '+'.join(str(s) for s in self.people.all()))
